/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vue;

/**
 *
 * @author Florian Minin & Khémon Beh
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public abstract class TableModele<M> extends AbstractTableModel {

    protected String[] nomsColonnes;
    protected List<M> donnees = new ArrayList<M>();

    public TableModele() {
    }

    public TableModele(ArrayList<M> tab) {
        donnees = tab;
    }

    public int getRowCount() {
        return donnees.size();
    }

    public int getColumnCount() {
        return nomsColonnes.length;
    }

    public M getObjetSelectionne(int row) {
        return donnees.get(row);
    }

    public void maj(List<M> l) {
        donnees = l;
        fireTableDataChanged();
    }

    public void supprimeLigne(int selectedRow) {
        donnees.remove(selectedRow);
        fireTableDataChanged();
    }

    @Override
    public String getColumnName(int col) {
        return nomsColonnes[col];
    }

    public List<M> getDonnees(){
        return donnees;
    }

    public abstract Object getValueAt(int row, int col);
}
